import pytesseract
from PIL import Image

# 打开图片

def img2text(img2):
    # img = Image.open(r'E:\auto\PythonProject1\testimage\a1.png')
    # 使用Tesseract进行文字识别
    text = pytesseract.image_to_string(img2, lang='chi_sim')
    return text
#
# import paddleocr
#
# # e:\Program Files\Tesseract-OCR
#
# # 创建一个OCR识别器
# ocr = paddleocr.ocr()
# # 读取图片
# img_path = r'E:\auto\PythonProject1\testimage\a1.png'
# img = paddleocr.read_image(img_path)
# # 进行文字识别
# result = ocr.ocr(img)
# # 显示识别结果
# for line in result:
#     print(' '.join((word_info[-1] for word_info in line)))


# import easyocr
#
# # def initReader():
# #     reader = easyocr.Reader(['ch_sim', 'en'], gpu=False)  # this needs to run only once to load the model into memory
# #     return reader
#
#
#
# def orcimage(img):
#     # reader = easyocr.Reader(['ch_sim','en'], gpu=False)
#     # result = reader.readtext(r'E:\auto\PythonProject1\testimage\a1.png',detail = 0)
#     reader = easyocr.Reader(['ch_sim', 'en'], gpu=False)  # this needs to run only once to load the model into memory
#     result = reader.readtext(img, detail=0)
#     print('orcinage result--->',result)
#     return  result